<template>
  <div class="snow-page">
    <div class="snow-inner">
      <!-- <a-form ref="formRef" auto-label-width :model="formData.form">
          <a-row :gutter="16">
            <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="6" :xxl="6">
              <a-form-item field="name" label="乡镇">
                <a-input v-model="formData.form.name" placeholder="请输入乡镇" allow-clear />
              </a-form-item>
            </a-col>
            <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="6" :xxl="6">
              <a-form-item field="name" label="管理级别">
                <a-input v-model="formData.form.name" placeholder="请输入管理级别" allow-clear />
              </a-form-item>
            </a-col>
            <a-col :xs="24" :sm="24" :md="12" :lg="12" :xl="6" :xxl="6">
              <a-space class="search-btn">
                <a-button type="primary" @click="getCommonTableList">
                  <template #icon>
                    <icon-search />
                  </template>
<template #default>查询</template>
</a-button>
<a-button @click="onReset">
  <template #icon>
                    <icon-refresh />
                  </template>
  <template #default>重置</template>
</a-button>

</a-space>
</a-col>
</a-row>
</a-form> -->
      <a-table row-key="key" size="small" :bordered="{
        cell: true
      }" :scroll="{ x: '100%', y: '100%', minWidth: 1000 }" :loading="loading" :columns="columns" :data="tableData"
        :row-selection="rowSelection" v-model:selectedKeys="selectedKeys" :pagination="pagination"
        @page-change="pageChange" @page-size-change="pageSizeChange">


        <template #optional>
          <a-space>
            <a-button size="mini" type="primary">详情</a-button>
            <a-button size="mini">修改</a-button>
            <a-popconfirm content="确定删除这条数据吗?" type="warning">
              <a-button size="mini" type="primary" status="danger">删除</a-button>
            </a-popconfirm>
          </a-space>
        </template>
      </a-table>
    </div>
  </div>
</template>

<script setup lang="ts">
import { getsourceSolidList } from "@/api/modules/sourceSolid/index";
// import { getCommonTableListAPI } from "@/api/modules/table/index";
import { List, FormData, RowSelection, Pagination } from "./config";
const formData = reactive<FormData>({
  form: {
    name: "",
    phone: "",
    email: "",
    address: "",
    status: null
  },
  search: false
});
const selectedKeys = ref<string[]>([]);
const rowSelection = reactive<RowSelection>({
  type: "checkbox",
  showCheckedAll: true,
  onlyCurrent: false
});
const pagination = ref<Pagination>({ showPageSize: true, showTotal: true, current: 1, pageSize: 10, total: 10 });
const pageChange = (page: number) => {
  pagination.value.current = page;
};
const pageSizeChange = (pageSize: number) => {
  pagination.value.pageSize = pageSize;
};
const columns = [
{
    title: "序号",
    width: 70,
    render: ({ rowIndex }: { rowIndex: number }) => {
      return rowIndex + 1
    }
  },
  {
    title: "企业名称",
    dataIndex: "name",
    width: 140
  },
  {
    title: "企业地址",
    dataIndex: "addr",
  
    align: "center",
    width: 200
  },
  {
    title: "固废类别",
    dataIndex: "type",
    width: 120
  },
  {
    title: "本年生产量",
    dataIndex: "thisYearProduction",
    width: 120
  },
  {
    title: "上年底贮存量",
    dataIndex: "lastYearEndStore",
    width: 120
  },
  {
    title: "本年底贮存量",
    dataIndex: "thisYearEndStore",
    align: "center",
   
    width: 120
  },
  {
    title: "贮存设施",
    dataIndex: "storeFacility",
    width: 120
  },
  {
    title: "贮存方式",
    dataIndex: "storeType",
    width: 120
  },
  {
    title: "利用贮存量",
    dataIndex: "useDisposeAmount",
    width: 120
  },
  {
    title: "利用方式",
    dataIndex: "disposeType",
    width: 120
  },
  //综合利用产品
  {
    title: "综合利用产品",
    dataIndex: "integratedProduction",
    width: 120
  },
  // {
  //   title: "操作",
  //   slotName: "optional",
  //   align: "center",
  //   fixed: "right",
  //   width: "200"
  // }
];
const formRef = ref();
const onReset = () => {
  formRef.value.resetFields();
  getCommonTableList();
};
const loading = ref<boolean>(false);
const tableData = ref([]);
const getCommonTableList = async () => {
  let obj = {
    "sourceSolidDtoFilter": {},
    "orderParam": null,
    "pageParam": {
      "pageNum": pagination.value.current,
      "pageSize": pagination.value.pageSize,
      "count": true
    }
  }
  try {
    loading.value = true;
    let res = await getsourceSolidList(obj);
    // Object.assign(data, res.data.list);
    tableData.value = res.data.dataList
    pagination.value.total = res.data.totalCount;
  } finally {
    loading.value = false;
  }
};
getCommonTableList();
</script>

<style lang="scss" scoped>
.search-btn {
  margin-bottom: 20px;
}
</style>